<template>
	<view class="zone">
		<Header title="市场记录"></Header>
		<view class="main">
			<image class="yun" src="http://image.qxgm.site/tdz/img/public/m_yun.png" mode="widthFix"></image>
			<image class="ping1" src="http://image.qxgm.site/tdz/img/public/ping1.png" mode="widthFix"></image>
			<view class="box">

				<scroll-view scroll-y class="scrollbox" @scrolltolower="scrolltolower">
					<view class="list">
						<view class="item" v-for="(item , index) in list" :key="index">
							<view class="time">
								上架时间:{{item.create_time}}
							</view>
							<view class="left">
								<view class="word">
									<p class="wp1">{{item.type_name}}{{item.deal_name}}</p>
									<view class="sann">
										<view class="sani">
											数量:<text class="color">{{item.total_num}}个</text>
										</view>
										<view class="zhanwei">

										</view>
										<view class="sani">
											单价:<text class="color">{{item.price}}灵石</text>
										</view>
									</view>

								</view>
								<view class="tjaisian">{{item.deal_type==1?'-':'+'}}{{((item.total_num-item.left_num)*item.price).toFixed(2)}}灵石
								</view>
							</view>
						</view>

						<view class="empty" v-if="list == ''">
							<image src="http://img.cpgm.cc/xfmz/static/public/empty.png" mode="widthFix" />
							<text>数据为空</text>
						</view>
						<u-loadmore v-else :status="status" color="rgba(255,255,255,0.65)" :icon-type="iconType"
							:load-text="loadText" />
					</view>
				</scroll-view>


			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				max_page: 1,
				list: '',
				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '没有更多了'
				},
			}
		},
		onLoad() {
			this.myBuyList();
		},
		onShow() {

		},
		methods: {
			// 下拉加载
			scrolltolower() {
				if (this.page >= this.max_page) {
					this.status = 'nomore'
					return;
				}
				this.status = 'loading';
				this.page = ++this.page;
				this.myBuyList();
				setTimeout(() => {
					if (this.page > this.max_page || this.page == this.max_page) this.status = 'nomore';
					else this.status = 'loading';
				}, 500)
			},

			// 我的求购列表
			async myBuyList() {
				let res = await this.$http.index.marketBuylog({
					page: this.page,
				})
				if (res.code == 1) {
					this.list = [...this.list, ...res.data.data];
					this.max_page = res.data.last_page;
					if (this.page > this.max_page || this.page == this.max_page) this.status = 'nomore';
				}
			},
		}
	}
</script>

<style lang="less">
	.zone {
		min-height: 100vh;
		background: url(http://image.qxgm.site/tdz/img/public/p_bg.png) no-repeat;
		background-size: 100% auto;
	}

	.main {
		width: 100%;
		position: relative;
		margin-top: 10px;
	}

	.yun {
		position: absolute;
		top: -4%;
		left: 0;
		width: 44%;
		z-index: 9;
	}

	.ping1 {
		width: 100%;
		display: flex;
	}

	.box {
		background: url(http://image.qxgm.site/tdz/img/public/ping2.png);
		background-size: 100% auto;
		padding: 0px 6px 9px;
	}

	.item {
		background: url(http://image.qxgm.site/tdz/img/market/mg-07.png) no-repeat;
		background-size: 100% 100%;
		margin-bottom: 4px;

		.time {
			font-size: 12px;
			color: #FFFFFF;
			font-weight: normal;
			line-height: 12px;
			padding: 4px 0 4px 7px;
			margin-left: 1px;
			background: url(http://image.qxgm.site/tdz/img/market/mg-06.png) no-repeat;
			background-size: 100% 100%;
		}

		.left {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 14px 31px 21px 22px;



			.word {

				.sann {
					display: flex;
					align-items: center;
				}

				.wp1 {
					font-size: 16px;
					font-weight: normal;
					color: #333333;
					line-height: 18px;
					margin-bottom: 8px;
				}

				.zhanwei {
					width: 10px;
				}

				.color {
					color: #FF0000;
				}

				text {
					font-weight: normal;
					font-size: 15px;
					color: #333333;
					line-height: 15px;
				}

			}

			.tjaisian {
				font-size: 20px;
				font-weight: normal;
				color: #336633;
				line-height: 24px;
			}
		}


	}

	.scrollbox {
		height: calc(100vh - 106px);
		overflow-y: scroll;
	}

	.fachubtn {
		display: block;
		margin: 18px auto;
		width: 116px;
		height: 37px;
		text-align: center;
		font-size: 16px;
		color: #fef7c8;
		text-shadow: 0 1px 1px #CB6500;
		line-height: 37px;
		font-weight: normal;
		background: url(http://image.qxgm.site/tdz/img/public/anniu.png) no-repeat;
		background-size: 100% 100%;
	}
</style>